#####################################################################
# Product:      KnowledgeEngine (Plone Edition)
#
# File:         EventDefinition.py
#
# Copyright:    Copyright (c) 2004, Faulkner Technologies
#
# Author:       Brian Oliver
#
# Description:  A EventDefinition is an object that represents
#               runtime type information pertaining to a user-defined
#               event occuring on a GenericObject
#
# See Also:     EventReflection
#####################################################################

#####################################################################
## KnowledgeEngine Library Imports
from Common import *

#####################################################################
## Zope Library Imports
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl.Role import RoleManager
 
#####################################################################
## Python Library Imports
# (none)

#####################################################################
## The Event Types Supported 
## (may be or'd together to signal multiple types of support)

et_SERVER = 1
et_BROWSER = 2

#####################################################################
## EventDefinition Class Definition
class EventDefinition(RoleManager):
    """
        Instances of this class define individual event information
        for enericObjects
    """
        
    #---------------------------------------------------------------#

    #declare security so EventDefinitions may be accessed in DTML/ZPT etc
    security = ClassSecurityInfo()
    security.declareObjectPublic()
    security.setDefaultAccess("allow")

    #---------------------------------------------------------------#

    def __init__(self, identity, displayName, description="", eventType=et_SERVER):
        """
            Stores the state of a Property Definition.
            
            PARAMETERS:

            identity:                   The identity of the event, eg: onAfterSubmit
    
            displayName:                What the end-user sees as the name of the event
    
            description:                A description of the event (what it captures)
            
            eventType:                  The type of event, typically et_SERVER (although et_BROWSER is also available)
                                        (types may be order together to support multiple types of events)
    
        """        
        
        self.identity = identity
        self.displayName = displayName
        self.description = description
        self.eventType = eventType
        
    #---------------------------------------------------------------#

    def getIdentity(self):
        """
            Returns the unique identity for the event, which is 
            used to identify the event in an object
            
            RETURN TYPE: String
        """
        
        return self.identity

    #---------------------------------------------------------------#

    def getDisplayName(self):
        """
            Returns the string name for the event used to display
            and construct event editors
            RETURN TYPE: String
        """
        
        return self.displayName

    #---------------------------------------------------------------#

    def getDescription(self):
        """
            Returns the string description for the event.  Used to 
            display construct property editors
            RETURN TYPE: String
        """
        
        return self.description

    #---------------------------------------------------------------#

    def getType(self):
        """
            Returns the event type.  Event types are defined in this 
            file
        """
        
        return self.eventType
        
    #---------------------------------------------------------------#
        
#####################################################################
## Class Initialisation
InitializeClass(EventDefinition)
